﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using System.Reactive.Linq;



namespace RxTestbed
{
    class Program
    {
        static void Main(string[] args)
        {
            //TextPerLine();
            RxEvent();


            Console.ReadLine();
        }

        

        static void TextPerLine()
        {
            var xs = "Hello, world".ToObservable();

            xs.Subscribe(x => Console.WriteLine(x));


        }

        static void RxEvent()
        {
            //this is the "event declaration"
            var s = new Subject<int>();

            //This is the subscribe.
            //when the event triggers, do this function
            var d = s.Subscribe(x => Console.WriteLine(x));
            
            //fires the event, and passes whatever information it needs to pass
            //pass to receiving function
            s.OnNext(42);

            //Subscribe returns an IDisposable, so you can use the return value
            //of a Subscribe call to effectively unsubscribe
            d.Dispose();

            s.OnNext(44);


        }

       


        static void ActionEvent()
        {
            
        }


        static void RxTimer()
        {
            
        }
    }
}
